import axios from "axios"

// 引入get post模块
import { GET, POST } from "./config"
const instance = axios.create({
    baseURL: 'http://api.kudesoft.cn/tdk',
    // 请求超时时长
    timeout: 10000,
    //设置axios为form-data
   headers:{'Content-Type':'application/x-www-form-urlencoded'},

   transformRequest:[function (data) {
    let ret = ''
    for (let it in data) {
      ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
    }
    return ret
  }]
});

// 请求得到数据返回给页面
export function respust(method, url, params) {
    switch (method) {
        case GET:
            return get(url, params)
        case POST:
            return post(url, params)
    }
}

function get(url, params) {
    return instance.get(url, params)
}
function post(url, params) {
    return instance.post(url, params)
}


